package org.doubango.ngn.services.facade;

import org.doubango.ngn.services.INgnConfigurationService;
import org.doubango.ngn.services.INgnContactService;
import org.doubango.ngn.services.INgnHistoryService;
import org.doubango.ngn.services.INgnHttpClientService;
import org.doubango.ngn.services.INgnNetworkService;
import org.doubango.ngn.services.INgnSipService;
import org.doubango.ngn.services.INgnSoundService;
import org.doubango.ngn.services.INgnStorageService;

/**
 * @author dpGroup
 *
 */
public class NgnServiceFacade {

	INgnConfigurationService configurationService;
	INgnContactService contactService;
	INgnHistoryService historyService;
	INgnHttpClientService clientService;
	INgnNetworkService networkService;
	INgnSipService sipService;
	INgnSoundService soundService;
	INgnStorageService storageService;
	
	public NgnServiceFacade(INgnConfigurationService configurationService,
			INgnContactService contactService,
			INgnHistoryService historyService,
			INgnHttpClientService clientService,
			INgnNetworkService networkService, INgnSipService sipService,
			INgnSoundService soundService, INgnStorageService storageService) {
		this.configurationService = configurationService;
		this.contactService = contactService;
		this.historyService = historyService;
		this.clientService = clientService;
		this.networkService = networkService;
		this.sipService = sipService;
		this.soundService = soundService;
		this.storageService = storageService;
	}
	
	public boolean startAllServices(){
		boolean retFlag = true;
		
		if(this.configurationService ==  null){
			retFlag &= this.configurationService.start();				
		}
		
		if(this.contactService ==  null){
			retFlag &= this.contactService.start();				
		}
		
		if(this.historyService ==  null){
			retFlag &= this.historyService.start();				
		}
		
		if(this.clientService==  null){
			retFlag &= this.clientService.start();				
		}
		
		if(this.networkService ==  null){
			retFlag &= this.networkService.start();				
		}
		
		if(this.sipService ==  null){
			retFlag &= this.sipService.start();				
		}
		
		if(this.soundService ==  null){
			retFlag &= this.soundService.start();				
		}

		if(this.storageService==  null){
			retFlag &= this.storageService.start();				
		}
		
		return retFlag;
		
	}
	
	public boolean stopAllServices(){
		boolean retFlag = true;
		
		if(this.configurationService ==  null){
			retFlag &= this.configurationService.stop();				
		}
		
		if(this.contactService ==  null){
			retFlag &= this.contactService.stop();				
		}
		
		if(this.historyService ==  null){
			retFlag &= this.historyService.stop();				
		}
		
		if(this.clientService==  null){
			retFlag &= this.clientService.stop();				
		}
		
		if(this.networkService ==  null){
			retFlag &= this.networkService.stop();				
		}
		
		if(this.sipService ==  null){
			retFlag &= this.sipService.stop();				
		}
		
		if(this.soundService ==  null){
			retFlag &= this.soundService.stop();				
		}

		if(this.storageService==  null){
			retFlag &= this.storageService.stop();				
		}
		
		return retFlag;
		
	}	
	
	
}
